package com.ds.lens.data.service.dao.sql.provider;

import com.ds.lens.data.service.dao.entity.LensRoleResourceRelation;
import org.apache.ibatis.jdbc.SQL;

public class LensRoleResourceRelationSqlProvider {

    public String insertSelective(LensRoleResourceRelation record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lens_role_resource_relation");

        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getRuleId() != null) {
            sql.VALUES("rule_id", "#{ruleId,jdbcType=BIGINT}");
        }

        if (record.getResourceId() != null) {
            sql.VALUES("resource_id", "#{resourceId,jdbcType=BIGINT}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LensRoleResourceRelation record) {
        SQL sql = new SQL();
        sql.UPDATE("lens_role_resource_relation");

        if (record.getRuleId() != null) {
            sql.SET("rule_id = #{ruleId,jdbcType=BIGINT}");
        }

        if (record.getResourceId() != null) {
            sql.SET("resource_id = #{resourceId,jdbcType=BIGINT}");
        }

        sql.WHERE("id = #{id,jdbcType=BIGINT}");

        return sql.toString();
    }
}
